/*
 * Copyright 2009 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.splink.deepsplink.interceptor {

	/**
	 * An <code>IInterceptor</code> implementation can be added to an
	 * <code>IDeeplinkController</code> implementation. Before executing any
	 * page change request the <code>IDeeplinkController</code> invokes the 
	 * <code>intercept</code> method of each previously added <code>IInterceptor</code>. 
	 * The <code>IInterceptor</code>s <code>intercept</code> method inspects the 
	 * given pageId and parameters. Then it either returns <code>false</code>
	 * or <code>true</code> and redirects to the configured redirectId.
	 * 
	 * @author Max Kugland
	 */
	public interface IInterceptor {
		/**
		 * The given page id is inspected and if any interception rules apply
		 * <code>true</code> is returned, otherwise <code>false</code> is
		 * returned and <code>IDeeplinkController</code> proceeds with changing
		 * to the new page
		 * 
		 * @param id the id to be intercepted
		 * @param pageParams the appendent page parameters
		 * @return a Boolean value indicating whether the request was intercepted
		 */
		function intercept(id : String, pageParams : Array) : Boolean;

		/**
		 * Returns the last intercepted id.
		 * 
		 * @return the intercepted id 
		 */
		function get lastInterceptedId() : String;
	}
}
